﻿using IterationLife.FootballTeaching.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.FootballTeachings {
    /// <summary>
    /// 章节数据传输对象扩展
    /// </summary>
    public static class ChapterDtoExtension {
        /// <summary>
        /// 转换为章节实体
        /// </summary>
        /// <param name="dto">章节数据传输对象</param>
        public static Chapter ToEntity( this ChapterDto dto ) {
            if ( dto == null )
                return new Chapter();
            return dto.MapTo( new Chapter( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为章节数据传输对象
        /// </summary>
        /// <param name="entity">章节实体</param>
        public static ChapterDto ToDto(this Chapter entity) {
            if( entity == null )
                return new ChapterDto();
            return entity.MapTo(new ChapterDto());
        }
    }
}
